package com.wthink.hzgj.wireless.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wthink.hzgj.data.Result
import com.wthink.hzgj.service.DevService
import com.wthink.hzgj.wireless.Wireless
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class WirelessViewmodel : ViewModel(){

    val wireless = MutableLiveData(
        Wireless("","","","",""
            ,"","","","","")
    )

    fun queryWireless(){
        viewModelScope.launch(Dispatchers.IO) {
            val wirelessInfo = DevService.queryWirelessInfo()
            if (wirelessInfo is Result.Success) {
                val data = wirelessInfo.data
                wireless.postValue(data)
            }
        }
    }
}